package com.efuture.reflect;

/**
 * @ClassNAME ReflectSuperClass
 * @Description 通过反射获取父类和父接口
 * @Author zhaoshanshan
 * @Date 2021/9/11 10:14 下午
 * @Version 1.0
 */
public class ReflectSuperClass {

    public static void main(String[] args) {
        try {
            Class stringClass = Class.forName("java.lang.String");
            //获取stringClass父类
            Class superClass = stringClass.getSuperclass();
            System.out.println(superClass);
            Object o = superClass.newInstance();
            System.out.println(o);
            //获取stringClass父接口
            Class[] interfaces = stringClass.getInterfaces();
            for (Class c:interfaces){
                System.out.println(c);
            }


        }catch (Exception e){
            e.getStackTrace();
        }
    }
}